#include "Window/OpenGLClass.h"
#include "Input Control/InputControl.h"
#include <iostream>

#include "ObjectConstruction/ObjectManager.h"
#include "ObjectConstruction/ObjectRead.h"
#include "Math/MathCode.h"

// We need libraries, they have books and predefined code
#pragma comment (lib,"opengl32.lib")
#pragma comment (lib,"glu32.lib")

// We are using the standard namespace
using namespace std;

Input TestInput;

OpenGLWindow c;

// He's a G Knee Us
long ProfessorGenius(Window &Wnd, long Anum, long Bnum)
{
	cout << "Sizing window, genie - us!" << endl;
	return Wnd.DefWndSize(Wnd, Anum, Bnum);
}

long KeyDown(Window &Wnd, long Anum, long Bnum)
{
	TestInput.SetDown( Anum );
	
	return 0;
}

long KeyUp(Window &Wnd, long Anum, long Bnum)
{
	TestInput.SetUp( Anum );
	return 0;
}

void CloseWindow()
{
	c.NotifyWndClose();
	return;
}

// It's main
int main (void)
{
  ObjectManager< int,Vector<double,2> > a( &ReadInVector );
  a.GenerateObject( "Square", "Square.txt", true );

	c.RegisterProc( WM_SIZE , ProfessorGenius );
	c.RegisterProc( WM_KEYDOWN , KeyDown );
	c.RegisterProc( WM_KEYUP , KeyUp );

	TestInput.RegisterDgtlProc( 'J' , TRIGGERED , CloseWindow );

	if (c.Create())
	{
		cout << "Hurray!" << endl;
	}
	else
	{
		cout << "Boo!" << endl;
	}

	c.ShowWnd( SW_SHOWNORMAL );

	while( Window::ActiveWndCount() )
	{
		c.HandleMsgs();
		TestInput.Update();
	}

	cout << "Good bye :(" << endl;

	return 0;
}